package com.xw.dao;

import com.xw.entity.Thumbs;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * @Description: 点赞/收藏模块(Thumbs)表数据库访问层
 * @Author: ASUS
 * @Date: 2024/12/19 9:17
 * @Version: 1.0
 */


@Mapper
public interface ThumbsDao {

    /**
     * @param thumbs 实例对象
     * @return 影响行数
     * @Description 添加Thumbs
     * @author makejava
     * @date 2024-08-05 13:30:03
     */
    int insert(Thumbs thumbs);

    /**
     * @param id 主键
     * @return 影响行数
     * @Description 删除Thumbs
     * @author makejava
     * @date 2024-08-05 13:30:03
     */
    int deleteById(Integer id);

    /**
     * 批量删除
     *
     * @param ids
     */
    void deleteBatchByIds(@Param("ids") List<Integer> ids);

    /**
     * @param id 主键
     * @return 实例对象
     * @Description 查询单条数据
     * @author makejava
     * @date 2024-08-05 13:30:03
     */
    Thumbs queryById(Integer id);

    /**
     * @return 对象列表
     * @Description 查询全部数据
     * @author makejava
     * @date 2024-08-05 13:30:03
     * 分页使用MyBatis的插件实现
     */
    List<Thumbs> queryAll();

    /**
     * @param thumbs 实例对象
     * @return 对象列表
     * @Description 实体作为筛选条件查询数据
     * @author makejava
     * @date 2024-08-05 13:30:03
     */
    List<Thumbs> queryAll(Thumbs thumbs);

    /**
     * @param
     * @return 影响行数
     * @Description 修改Thumbs
     * @author makejava
     * @date 2024-08-05 13:30:03
     */
    int update(Thumbs thumbs);

    Thumbs queryByAll(Thumbs thumbs);


    @Delete("delete from thumbs where link_id = #{linkId} and user_id = #{userId} and type = #{type}")
    void deleteByLinkIdAndUserId(@Param("linkId") Integer linkId, @Param("userId") Integer userId,@Param("type") Integer type);

    List<Map<String, Object>> getHighRankPosts();

    @Delete("delete from thumbs where link_id = #{id}")
    void deleteByPostId(Integer id);
}
